package com.joysuch.wwyt.workflow.repository;

import com.joysuch.wwyt.workflow.entity.WorkFlowScreenType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author ZhangDong
 * @Date 2020/11/30 13:21
 */
public interface WorkFlowScreenTypeDao extends JpaRepository<WorkFlowScreenType, Long> {

    int countByTypeName(String typeName);

    @Query("select t.typeName from WorkFlowScreenType t where id in (:idList)")
    List<String> findTypeNameByIdIn(List<Long> idList);

    WorkFlowScreenType findFirstByTypeName(String typeName);

    int countByCode(String code);

    @Query(value = "SELECT * FROM wwyt_workflow_screen_type WHERE delete_flag = '0' AND is_show = 1 ORDER BY show_number", nativeQuery = true)
    List<WorkFlowScreenType> findByIsShowAndShowNumberDesc();

    @Query(value = "SELECT code FROM wwyt_workflow_screen_type WHERE delete_flag = '0' AND id =?1", nativeQuery = true)
    String getCodeById(Long typeId);

    WorkFlowScreenType findFirstByCode(String typeCode);

    WorkFlowScreenType findByCode(String mh);
}
